package com.my.mall.client.home.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.my.mall.client.home.dao.HomeClientDao;
import com.my.mall.client.home.vo.HomeClientVo;

@Service
public class HomeClientService {

	@Autowired
	HomeClientDao homeClientDao;

	public int selectHomeInfoCount() {
		return homeClientDao.selectHomeInfoCount();
	}

	public Map<String, List<HomeClientVo>> selectHomeInfoList() {
		Map<String, List<HomeClientVo>> map = new HashMap<>();
		List<HomeClientVo> categoryIDList = homeClientDao.selectCategoryList();
		for (HomeClientVo hcv : categoryIDList) {
			List<HomeClientVo> list = homeClientDao.selectHomeInfoList(hcv.getCategoryID(), 0, 5);
			map.put(hcv.getCategoryName(), list);
		}
		return map;
	}
}
